
const mysql = require('mysql');
const connection = mysql.createConnection({
  host : '127.0.0.1',
  user : 'root',
  password : 'root',
  database : 'baixiu'
});

module.exports = {
  // 获取所有分类
  getAllCategory(callback){
    let sql = `SELECT * FROM categories`;
    connection.query(sql,(err,result)=>{
      callback(err,result);
    });
  },
  addNewCategory(data,callback){
    let sql = `INSERT INTO categories SET \`NAME\`='${data.name}',slug='${data.slug}',classname='${data.classname}'`;
    connection.query(sql,(err,result)=>{
      callback(err,result);
    });
  },

  
}